<!DOCTYPE html>
<html>
<head>
   <title>CSS Animations - animation shorthand before animation longhand</title>
   <link rel="author" title="Opera Software ASA" href="http://www.opera.com/">
   <link rel="help" href="http://dev.w3.org/csswg/css3-animations/#the-animation-shorthand-property-">
   <meta name="flags" content="dom">
   <meta name="assert" content="The animation shorthand can be partially
   overridden by animation-* longhands that have higher weight in the cascade">
   <script src="/resources/testharness.js"></script>
   <script src="/resources/testharnessreport.js"></script>
   <style type="text/css">
      @keyframes move {
         from {
            left: 0px;
         }
         to {
            left: 100px;
         }
      }
      div {
         width: 100px;
         height: 100px;
         background: blue;
         position: relative;
      }
      .test {
         animation: move 0.5s 3 alternate forwards;
         animation-iteration-count: 2;
      }
   </style>
   <script type="text/javascript">
      setup({explicit_done:true});
      onload = function() {
         var testName = document.querySelector('title').firstChild.data;
         var div = document.querySelector('div');
         var log = document.querySelectorAll('p')[1].firstChild;
         function aboutEqual(observed, actual) {
            var maxDeviation = 100;
            return (Math.abs(observed - actual) < maxDeviation);
         }
         var timeout = setTimeout(function() {
            test(function(){assert_true(false);}, testName); done();
            log.data = 'FAIL';
         }, 1500);
         div.addEventListener('animationend', function() {
            clearTimeout(timeout);
            var passed = (aboutEqual(Date.now() - startTime, 1000)
                          && getComputedStyle(div, null).left == '0px');
            test(function(){assert_true(passed);}, testName); done();
            log.data = (passed ? 'PASS if the animation occurred.' : 'FAIL');
         });
         var startTime = Date.now();
         div.className = 'test';
      }
   </script>
   <style>iframe{display:none}</style>
</head>
<body>
   <p>The blue square below should slide rightwards, then back left again.</p>
   <p>Testing...</p>
   <div></div>
</body>
</html>
